import { ApiProperty } from '@nestjs/swagger';
import { modelOptions, prop, Ref } from '@typegoose/typegoose';
import { Book } from './book.model';
import { Order } from './order.model';
import { User } from './user.model';

@modelOptions({
  schemaOptions: {
    timestamps: true,
  },
})
export class Car {
  @ApiProperty({ description: '用户ID', example: User })
  @prop({ ref: User, required: true })
  user: Ref<User>;

  @ApiProperty({ description: '图书ID', example: '图书ID' })
  @prop({ ref: Book, required: true })
  book: Ref<Book>;

  @ApiProperty({ description: '数量', example: 1 })
  @prop({ required: true })
  number: number;

  @ApiProperty({ description: '订单ID', example: 'xxxx' })
  @prop({ required: true, ref: () => Order })
  order: Ref<Order>;
}
